home *** CD-ROM | disk | FTP | other *** search
/ internet.au CDrom 42 / NETCD42.iso / web / w95 / dream2.exe / data1.cab / Program_Files / Configuration / Behaviors / Actions / Call JavaScript.js < prev    next >
Encoding:
JavaScript  |  1998-11-30  |  1.7 KB  |  76 lines

  1. // Copyright 1998 Macromedia, Inc. All rights reserved.
  2.  
  3. //*************** GLOBALS VARS *****************
  4.  
  5. //******************* BEHAVIOR FUNCTION **********************
  6.  
  7. //Evals a JavaScript string.
  8. //browser window. Passed the following arg:
  9. //  jsStr - a string
  10.  
  11. function MM_callJS(jsStr) { //v2.0
  12.   return eval(jsStr)
  13. }
  14.  
  15.  
  16. //******************* API **********************
  17.  
  18.  
  19. //Can be used with any tag and any event
  20.  
  21. function canAcceptBehavior(){
  22.   return true;
  23. }
  24.  
  25.  
  26.  
  27. //Returns a Javascript function to be inserted in HTML head with script tags.
  28.  
  29. function behaviorFunction(){
  30.   return "MM_callJS";
  31. }
  32.  
  33.  
  34.  
  35. //Returns fn call to insert in HTML tag <TAG... onEvent='thisFn(arg)'>
  36. //Calls escQuotes to find embedded quotes and precede them with \
  37.  
  38. function applyBehavior() {
  39.   var jsStr = escQuotes(document.theForm.message.value);
  40.   if (jsStr == '') {
  41.     return MSG_NoMsg;
  42.   } else {
  43.     return "MM_callJS('" + jsStr + "')";
  44.   }
  45. }
  46.  
  47.  
  48.  
  49. //Passed the function call above, takes prior arguments and reloads the UI.
  50. //Removes any escape characters \
  51.  
  52. function inspectBehavior(jsStr){
  53.   var startPos = jsStr.indexOf("(")+2;
  54.   var endPos = jsStr.lastIndexOf(")",jsStr.length)-1;
  55.   document.theForm.message.value = unescQuotes(jsStr.substring(startPos,endPos));
  56. }
  57.  
  58.  
  59.  
  60. //***************** LOCAL FUNCTIONS  ******************
  61.  
  62.  
  63. //Set the insertion point
  64.  
  65. function initializeUI(){
  66.   document.theForm.message.focus(); //set focus on textbox
  67.   document.theForm.message.select(); //set insertion point into textbox
  68. }
  69.  
  70.  
  71.  
  72. //**************** GENERIC FUNCTIONS ****************
  73.  
  74. //function escQuotes(theStr){
  75. //function unescQuotes(theStr){
  76.